package vip.xiaonuo.common.util;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import vip.xiaonuo.common.cache.CommonCacheOperator;

/**
 * @author zjt
 * @description
 * @date 2025/2/12 18:34
 */
@Component
public class CommonBatchNumberUtil {

    private static CommonCacheOperator cacheOperator;

    @Autowired
    public void setCacheOperator(CommonCacheOperator cacheOperator) {
        CommonBatchNumberUtil.cacheOperator = cacheOperator;
    }

    public static String getBatchNumber(String code) {
        return CommonDateUtil.getTodayStrB() + String.format("%05d", cacheOperator.getIncrAtomic(code, CommonDateUtil.getTodayDuration()));
    }
}
